import SwiftUI

// LoginPage
// 登录界面小窗口

struct LoginWindow: View {
    @Environment(\.modelContext) private var modelContext
    
    @Binding var phoneNumberInput: String
    @Binding var passwordInput: String
    
    @Binding var showRegister: Bool

    var body: some View {
        VStack {
            Text("欢迎回来")
                .font(.largeTitle)
                .foregroundColor(.black)
                .padding(.vertical, 20)
            
            LoginInput(phoneNumberInput: $phoneNumberInput,
                       passwordInput: $passwordInput)
                .padding(.bottom, 20)
            
            LoginButton(phoneNumberInput: $phoneNumberInput,
                        passwordInput: $passwordInput,
                        showRegister: $showRegister)
                .modelContext(modelContext)
                .padding(.bottom, 20)
        }
        .background(.white)
        .frame(maxWidth: 360)
        .cornerRadius(10)
    }
}

#Preview {
    @State var phoneNumberInput: String = ""
    @State var passwordInput: String = ""
    
    return LoginWindow(phoneNumberInput: $phoneNumberInput,
                       passwordInput: $passwordInput,
                       showRegister: .constant(false))
}
